package com.jbh.libapi

import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.HeaderMap
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import rx.Observable

interface ApiServer {
    /**
     * get请求
     *
     * @return
     */
    @GET("{page}")
    fun apiGet(@Path("page") page: String?): Observable<Any?>?


    /**
     * 表单形式上传数据
     *
     * @param map
     * @return
     */
    @FormUrlEncoded
    @POST("{page}")
    fun apiPost(@Path("page") page: String?, @FieldMap map: MutableMap<String, Any>): Observable<Any?>?

    /**
     * 使用 json 对象上传
     *
     * @param api
     * @param requestBody
     * @return
     */
    @POST("{api}")
    fun apiPost(@Path("api") api: String?, @Body requestBody: RequestBody?): Observable<Any?>


    /**
     * 使用 json 对象上传
     *
     * @param api
     * @param requestBody
     * @return
     */
    @POST("{api}")
    fun apiPost(
        @HeaderMap heads: Map<String?, Any?>?,
        @Path("api") api: String?,
        @Body requestBody: RequestBody?
    ): Observable<Any?>?

    /**
     * 文件上传
     *
     * MultipartBody.Builder
     *
     * @return
     */
    @Multipart
    @POST("{api}")
    fun uploadFile(@Path("api") api: String?, @Part body: MultipartBody.Part?): Observable<Any?>?
}
